﻿using UnityEngine;

public class PrivacyUI : MonoBehaviour
{
    public UIEventListener closebtn;

    public Animator animator;

    private GameObject objui;

    private bool isshow;

    private void Start()
    {
        closebtn.onClick = OnClickcloseBtn;
    }

    public void enable()
    {
        if (objui == null)
        {
            objui = base.gameObject;
        }
        UnityVersionUtil.SetActiveRecursive(objui, state: true);
        isshow = true;
        //scaleanima.Stop();
        animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        Invoke("animplay", Time.deltaTime * 2f);
    }

    public void animplay()
    {
        animator.SetTrigger("popWin1");
    }


    public void OnClickcloseBtn(GameObject btn)
    {
        if (isshow)
        {
            isshow = false;
            MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
            /* scaleanima["PopWinAnimation"].time = scaleanima.clip.length;
			scaleanima["PopWinAnimation"].speed = -1f;
			scaleanima.Play(); */
            animator.SetTrigger("popWin2");
            Invoke("disable", animator.GetCurrentAnimatorStateInfo(0).length/10);
        }
    }

    public void disable()
    {
        animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        MenuBackController.instance.BackMenuUIstate();
        UnityVersionUtil.SetActiveRecursive(objui, state: false);
    }
}
